<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"/>
    <title>HELLO，AMAP!</title>
    <style>
        html,
        body,
        #container {
          width: 100%;
          height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script type="text/javascript">
    window._AMapSecurityConfig = {
      securityJsCode: "8fd5ef2008f97350ca4cbeb17865bbdb",
    };
</script>
<script
        type="text/javascript"
        src="https://webapi.amap.com/maps?v=2.0&key=975ee561d6cb9a7281d33aabea38d6d9"
></script>
<script type="text/javascript">
    var zoom = 16
    //地图初始化应该在地图容器 <div> 已经添加到 DOM 树之后
    var map = new AMap.Map("container", {
      zoom: zoom, //地图的缩放级别
      center:[118.779105,31.991412] //地图的中心点坐标
    });

    //设置当前真实位置
    function setCurrentLocation(lon,lat){
        map.setZoomAndCenter(zoom, [lon, lat])//设置地图的缩放级别和中心点位置

        //创建一个当前位置的标记点
        var marker = new AMap.Marker({
            position: new AMap.LngLat(lon, lat),
            icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
            map:map
        });
        map.add(marker);

        map.plugin(['AMap.PlaceSearch'], function() {
            var PlaceSearchOptions = { //设置PlaceSearch属性
                map:map,
                pageSize: 4, //每页结果数,默认10
                pageIndex: 1, //请求页码，默认1
                extensions: "base" //返回信息详略，默认为base（基本信息）
            };
            var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类
            AMap.Event.addListener(MSearch, "complete", (result)=>{
                //result.poiList.pois:需要传递给鸿蒙端去使用，就需要调用鸿蒙的方法
                window.swift.receiveHtmlData(JSON.stringify(result.poiList.pois)) //json
                //alert(JSON.stringify())
            }); //返回结果
            MSearch.searchNearBy("停车场", [lon, lat]); //关键字查询
        });
    }

<!--    window.onload=function(){-->
<!--        setCurrentLocation(113.625979,34.740922)-->
<!--    }-->
</script>